let str=[1,4,3,3]
let set=new Set(str)
let data=Array.from(set)
console.log(data);

function fun(){
    console.log('我出生了');
    setTimeout(()=>{
       console.log('我长大了');
       setTimeout(()=>{
         console.log('我做了开发，年薪百万');
         setTimeout(()=>{
          console.log('80年后幸福的狗带');
         },3000)
       },2000)

    },1000)
}
// fun()
function prsm(todo,set){
     const add=new Promise((resolve, reject) => {
          setTimeout(function(){resolve(todo)},set)
     })
     return add
}
function sum(){
      console.log('我出生了');
      prsm('我长大了',1000).then((res) => {
           console.log(res);
           return prsm('我做了前端开发，年薪百万',2000)
      }).then((res)=>{
        console.log(res);
        return prsm('80年后幸福的狗带',3000)
      }).then((res)=>{
        console.log(res);
      })
}
// sum()

async function deng(){
    console.log('我出生了');
    console.log(await prsm('我长大了',1000));
    console.log(await prsm('我做了前端开发，年薪百万',2000));
    console.log(await prsm('80年后幸福的狗带',3000));
}
// deng()
async function add(){
    const div=document.createElement('div');
    const p=document.createElement('p');
    p.innerHTML='loading...';
    div.appendChild(p);
    document.body.appendChild(div);
    const imag=await logimg('https://static.runoob.com/images/demo/demo2.jpg');
    div.appendChild(imag);
    p.style.display='none'
}
// add()
function logimg(src){
     return new Promise((resolve, reject) => {
        const img=document.createElement('img')
        img.onload=()=>{
            resolve(img)
        }
        img.onerror=()=>{

        }
        img.src=src
     })
}
// logimg()
const doma=document.createElement('div');
doma.innerHTML='domA';
const domb=document.createElement('div');
domb.innerHTML='domB';
const domMap=new Map();
domMap.set(doma,false);
domMap.set(domb,true);
domMap.forEach((display,dom)=>{
    if(display)
    {
        document.body.appendChild(dom)
    }
})


